package com.itheima.abstractfactory;

public class AbstractFactory {
    public static void main() {
        Factory factory = new Factory1();
        ProductA productA = factory.createProductA();
        productA.info();
        ProductB productB = factory.createProductB();
        productB.info();
    }
}

interface Factory {
    public ProductA createProductA();
    public ProductB createProductB();
}

class Factory1 implements Factory {

    @Override
    public ProductA createProductA() {
        return new ProductA1();
    }

    @Override
    public ProductB createProductB() {
        return new ProductB1();
    }
}

class Factory2 implements Factory {

    @Override
    public ProductA createProductA() {
        return new ProductA2();
    }

    @Override
    public ProductB createProductB() {
        return new ProductB2();
    }
}

interface ProductA {
    public void info() ;
}

class ProductA1 implements ProductA {

    @Override
    public void info() {
        System.out.println("ProductA1");
    }
}

class ProductA2 implements ProductA {

    @Override
    public void info() {
        System.out.println("ProductA2");
    }
}

interface ProductB {
    public void info() ;
}

class ProductB1 implements ProductB {

    @Override
    public void info() {
        System.out.println("ProductB");
    }
}

class ProductB2 implements ProductB {
    @Override
    public void info() {
        System.out.println("ProductB2");
    }
}
